package com.canaan.business.controller.pc.bill;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.canaan.common.annotation.Log;
import com.canaan.common.core.controller.BaseController;
import com.canaan.common.core.domain.AjaxResult;
import com.canaan.common.enums.BusinessType;
import javax.annotation.Resource;
import com.canaan.business.domain.bill.ReceiveProductBillCheck;
import com.canaan.business.service.bill.IReceiveProductBillCheckService;
import com.canaan.common.utils.poi.ExcelUtil;
import com.canaan.common.core.page.TableDataInfo;

/**
 * 收货清单Controller
 *
 * @author ruoyi
 * @date 2023-02-10
 */
@Api(tags = "收货清单")
@RestController
@RequestMapping("/bill/refundCheck")
public class ReceiveProductBillCheckController extends BaseController {
    @Resource
    private IReceiveProductBillCheckService receiveProductBillCheckService;

    /**
     * 查询收货清单列表
     */
    @ApiOperation(value = "查询收货清单列表")
    @GetMapping("/list")
    public TableDataInfo list(ReceiveProductBillCheck receiveProductBillCheck) {
        startPage();
        List<ReceiveProductBillCheck> list = receiveProductBillCheckService.selectReceiveProductBillCheckList(receiveProductBillCheck);
        return getDataTable(list);
    }

    /**
     * 导出收货清单列表
     */
    @ApiOperation(value = "导出收货清单列表")
    @Log(title = "收货清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReceiveProductBillCheck receiveProductBillCheck) {
        List<ReceiveProductBillCheck> list = receiveProductBillCheckService.selectReceiveProductBillCheckList(receiveProductBillCheck);
        ExcelUtil<ReceiveProductBillCheck> util = new ExcelUtil<ReceiveProductBillCheck>(ReceiveProductBillCheck.class);
        util.exportExcel(response, list, "收货清单数据");
    }

    /**
     * 获取收货清单详细信息
     */
    @ApiOperation(value = "获取收货清单详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(receiveProductBillCheckService.selectReceiveProductBillCheckById(id));
    }

    /**
     * 新增收货清单
     */
    @ApiOperation(value = "新增收货清单")
    @Log(title = "收货清单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReceiveProductBillCheck receiveProductBillCheck) {
        return success(receiveProductBillCheckService.insertReceiveProductBillCheck(receiveProductBillCheck));
    }

    /**
     * 修改收货清单
     */
    @ApiOperation(value = "修改收货清单")
    @Log(title = "收货清单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReceiveProductBillCheck receiveProductBillCheck) {
        return toAjax(receiveProductBillCheckService.updateReceiveProductBillCheck(receiveProductBillCheck));
    }

    /**
     * 删除收货清单
     */
    @ApiOperation(value = "删除收货清单")
    @Log(title = "收货清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(receiveProductBillCheckService.deleteReceiveProductBillCheckByIds(ids));
    }
}
